//
//  ASSettingViewController.m
//  AttendenceSys
//
//  Created by 窦芳俊 on 16/1/24.
//  Copyright © 2016年 窦芳俊. All rights reserved.
//

#import "ASSettingViewController.h"
#import "ASSettingCell.h"
#import "ASSettingPassword.h"

@interface ASSettingViewController () <UITableViewDataSource, UITableViewDelegate, ASSettingCellDelegate>

@property (nonatomic, strong) UITableView*  setTableView;
@property (nonatomic, strong) NSArray*      setArray;

@end

@implementation ASSettingViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self setLeftButtonWithImageName:@"ic_back" bgImageName:nil];
    self.strNavTitle = @"设置";
    
    _setArray = @[@"修改密码", @"消息提醒设置"];
    
    // set tableView
    _setTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    _setTableView.frame = CGRectMake(0, 0, self.view.frame.size.width, 100);
    _setTableView.delegate = self;
    _setTableView.dataSource = self;
    _setTableView.backgroundColor = [UIColor whiteColor];
    _setTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [_setTableView registerClass:[ASSettingCell class] forCellReuseIdentifier:NSStringFromClass([ASSettingCell class])];
    [self.view addSubview:_setTableView];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

#pragma mark - UITableViewDelegate

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50.0f;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (indexPath.row == 0)
    {
        ASSettingPassword * psdVC = [[ASSettingPassword alloc] init];
        psdVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:psdVC animated:YES];
    }
}

#pragma mark - UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_setArray count];
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([ASSettingCell class])];
    
    [(ASSettingCell *)cell updateCellStatus:[_setArray objectAtIndex:[indexPath row]]];
    ASSettingCell *asCell = (ASSettingCell *)cell;
    asCell.delegate = self;
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}

#pragma mark - ASSettingCellDelegate

- (void)msgReminderSwitchChanged:(BOOL)status leftTitle:(NSString *)text
{
    if ([text isEqualToString:@"消息提醒设置"])
    {
        if (YES == status)
        {
            
        }
        else
        {
        }
    }
}

@end







